//
//  BankVerify.m
//  ChampoinPeso
//
//  Created by mac on 2025/2/20.
//

#import "BankVerify.h"
@interface BankVerify()
@property (nonatomic,strong)UIView *bankView;
@property (nonatomic,strong)UILabel *bank;

@end
@implementation BankVerify

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}
-(void)setupUI
{
    UIView *view = [UIView new];
    [self addSubview:view];
    view.backgroundColor = UIColor.clearColor;
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_offset(0);
        make.height.mas_equalTo(394);
    }];
    UIImageView *bgIV = [[UIImageView alloc] initWithFrame:self.bounds];
    bgIV.image = [UIImage imageNamed:@"bankbg"];
    [self addSubview:bgIV];
    [self sendSubviewToBack:bgIV];
    [bgIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_offset(0);
        make.bottom.mas_offset(-50);
    }];

    UILabel *name = [UILabel new];
    name.text = @"Confirm card number";
    name.textColor = HexColor(@"#212121");
    name.font = [UIFont systemFontOfSize:16 weight:UIFontWeightBold];
    [view addSubview:name];
    [name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(25);
        make.centerX.mas_equalTo(view);
    }];
    
    [view addSubview:self.bankView];
    [_bankView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(name.mas_bottom).offset(36);
        make.left.mas_offset(17);
        make.right.mas_offset(-17);
    }];
    UILabel *l = [UILabel new];
    l.textColor  = HexColor(@"#FFA004");
    l.text = @"Please check carefully and make sure your bank card number is correct";
    l.numberOfLines = 0;
    l.font = [UIFont systemFontOfSize:12];
    [view addSubview:l];
    [l mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_bankView.mas_bottom).offset(8);
        make.left.mas_offset(17*2);
        make.right.mas_offset(-17*2);
    }];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:@"confi"] forState:UIControlStateNormal];
    [view addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(16);
        make.right.bottom.mas_offset(-16);
        make.height.mas_equalTo(50);
    }];
    
    UIButton *close = [UIButton buttonWithType:UIButtonTypeCustom];
    [close setImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
    [self addSubview:close];
    [close mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.bottom.mas_offset(-20);
    }];
    [close addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
    [btn addTarget:self action:@selector(apply) forControlEvents:UIControlEventTouchUpInside];

}
-(void)close
{
    if (self.closeAction) {
        self.closeAction();
    }}
-(void)apply
{
    if(self.commitAction) {
        self.commitAction();
    }
}

-(UIView *)bankView{
    if (!_bankView) {
        _bankView = [UIView new];
        UIView *view = [UIView new];
        view.backgroundColor = UIColor.clearColor;
        [_bankView addSubview:view];
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.bottom.mas_offset(0);
        }];
        UILabel *lab = [UILabel new];
        lab.text = @"ID NO.";
        lab.textColor = DetailColor;
        lab.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
        [view addSubview:lab];
        [lab  mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_offset(17);
            make.top.mas_offset(0);
        }];
        UIView *bview = [UIView new];
        bview.backgroundColor = UIColor.whiteColor;
        bview.layer.cornerRadius = 8;
        [view addSubview:bview];
        [bview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_offset(17);
            make.right.mas_offset(-17);
            make.top.equalTo(lab.mas_bottom).offset(6);
            make.height.mas_equalTo(94);
            make.bottom.mas_offset(0);
        }];
        [bview addSubview:self.bank];
        [_bank mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_offset(13);
            make.centerY.mas_equalTo(bview);
        }];
    }
    return _bankView;

}
-(UILabel *)bank{
    if (!_bank) {
        _bank = [UILabel new];
        _bank.textColor = HexColor(@"#FF9F02");
        _bank.font = [UIFont systemFontOfSize:18 weight:UIFontWeightBold];
    }
    return _bank;

}

-(void)setIdNo:(NSString *)idNo
{
    _bank.text = @"2134 4567 7891 3124";
}
@end
